#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


# Program 1.3.9 - Factoring integers

Syntax:
python factors.py 3757208


Notes:
int(sys.argv[1]) == Long.parseLong(args[0])

sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

The stop value in Python's range method is non-inclusive, thus the +1.
https://docs.python.org/2/library/functions.html#range

'''

import sys


def main():
    ''' Print the prime factors of a given number '''

    number = int(sys.argv[1])
    unfactored = number


    for number in range(2, (unfactored/2) + 1):
        while unfactored % number == 0:
            unfactored /= number
            print number,

    if unfactored > 1:
        print unfactored,
    print


if __name__ == '__main__':
    main()
